package cn.bonoon.util;


public class TimeUtil {
	
	private static final String[] NAMES = {"秒", "分钟", "小时", "天"};
	
	public static final int MINUTE = 60;
	public static final int HOUR = 60 * MINUTE;
	public static final int DAY = 24 * HOUR;
	
	private static final int[] TIMES = {60, 60, 24};
	
	public static String toString(int seconds){
		return __toStr(0, seconds);
	}
	
	private static String __toStr(int deep, int value){
		String str = "";
		if(value > 0){
			
			if(deep < TIMES.length){
				int time = TIMES[deep];
				int temp = value % time;
				if(temp > 0) str = temp + NAMES[deep];
				return __toStr(deep + 1, value / time) + str;
			}
			
			return value + NAMES[deep];
		}
		return str;
	}
}
